package com.beiming.moudle.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beiming.moudle.auth.dao.WarehouseDao;
import com.beiming.moudle.auth.entity.WarehouseEntity;
import com.beiming.moudle.auth.service.WarehouserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WarehouseServiceImpl extends ServiceImpl<WarehouseDao,WarehouseEntity> implements WarehouserService {
   @Autowired
  private WarehouseDao warehouseDao;

    @Override
    public int getWareNum(int id) {
        QueryWrapper<WarehouseEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("product_id",id);
        return getOne(queryWrapper).getCurrentCnt();

    }

    @Override
    public int setWareNum(WarehouseEntity entity) {
        QueryWrapper<WarehouseEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("product_id",entity.getProductId());
        return warehouseDao.update(entity,queryWrapper);
    }

    @Override
    public int addWare(WarehouseEntity entity) {

        return     warehouseDao.insert(entity);
    }

}
